package com.job.client.posts.controller;


import com.job.client.common.result.ResponseResult;
import com.job.client.model.posts.pojo.Posts;
import com.job.client.posts.service.PostsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 职位的详细信息表 前端控制器
 * </p>
 *
 * @author fkl
 * @since 2023-12-07
 */
@RestController
@RequestMapping("/api/v1/client/posts")
@Api(tags = "职位服务接口文档")
public class PostsController {
    @Autowired
    private PostsService postsService;

    @PostMapping("/info")
    @ApiOperation("根据id获得职位信息")
    public ResponseResult getPostsInfo(@RequestBody String postsId){
        return postsService.getPostsInfo(postsId);
    }

    @PostMapping("/save")
    @ApiOperation("保存职位信息,要验证用户是否被企业认证")
    public ResponseResult savePosts(@RequestBody Posts posts, HttpServletRequest request){
        return postsService.savePosts(posts,request);
    }
    @GetMapping("/getByCompanyId")
    @ApiOperation("通过公司id获得全部的职位信息")
    public ResponseResult getByCompanyId(@RequestParam String companyId){
        return postsService.getByCompanyId(companyId);
    }
    @GetMapping("/getByCompanyId/page")
    @ApiOperation("分页查询公司id的职位信息")
    public ResponseResult getByCompanyIdByPage(@RequestParam String companyId,@RequestParam Integer page,@RequestParam Integer size){
        return postsService.getByCompanyIdByPage(companyId,page,size);
    }
    @PostMapping("/all/info/list")
    @ApiOperation("根据postsId数组返回posts、user、company的信息")
    public ResponseResult getAllInfoList(@RequestBody List<String> postsIds){
        return postsService.getAllInfoList(postsIds);
    }

    @GetMapping("/getByUserId/page")
    @ApiOperation("分页查询用户id的职位信息")
    public ResponseResult getByUserIdByPage(@RequestParam String userId,@RequestParam Integer page,@RequestParam Integer size){
        return postsService.getByUserIdByPage(userId,page,size);
    }

    @GetMapping("/count/company")
    @ApiOperation("通过companyId获得职位的数量")
    public ResponseResult getCountByCompanyId(@RequestParam String companyId){
        return postsService.getCountByCompanyId(companyId);
    }
}
